package com.tlxch.controller.general;

import com.tlxch.constant.Message;
import com.tlxch.dto.DeepSeekdto;
import com.tlxch.pojo.DeepSeek;
import com.tlxch.result.Result;
import com.tlxch.server.general.DeepSeekService;
import com.tlxch.vo.AssessMsgvo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Api(tags = "接入Deepseek相关接口")
@Slf4j
@RestController
@RequestMapping("/deepseek")
public class DeepSeekController {

    @Autowired
    DeepSeekService deepSeekService;

    @PostMapping("/getDeepSeekResponse")
    @ApiOperation("获取Deepseek回复")
    public Result<List<AssessMsgvo>> getDeepSeekResponse(@RequestBody DeepSeekdto message) {
        log.info("收到消息:{}", message.getText());
        AssessMsgvo assessMsgvo = new AssessMsgvo();
        DeepSeek call = deepSeekService.call(Message.message1 + message.getText() + Message.message2);
        assessMsgvo.setSSid(message.getSSid());
        assessMsgvo.setSName(message.getSName());
        assessMsgvo.setTsContent(Collections.singletonList(call.getContent()));
        assessMsgvo.setTsScore(call.getFenshu());
        assessMsgvo.setTsLevel(call.getTsLevel());
        List<AssessMsgvo> list = new ArrayList<>();
        list.add(assessMsgvo);
        return Result.success(list);
    }
}